   1              		.syntax unified
   2              		.cpu cortex-m3
   3              		.fpu softvfp
   4              		.eabi_attribute 20, 1
   5              		.eabi_attribute 21, 1
   6              		.eabi_attribute 23, 3
   7              		.eabi_attribute 24, 1
   8              		.eabi_attribute 25, 1
   9              		.eabi_attribute 26, 1
  10              		.eabi_attribute 30, 4
  11              		.eabi_attribute 34, 1
  12              		.eabi_attribute 18, 4
  13              		.thumb
  14              		.syntax unified
  15              		.file	"misc.c"
  16              		.text
  17              	.Ltext0:
  18              		.cfi_sections	.debug_frame
  19              		.section	.text.flash_SaveLog,"ax",%progbits
  20              		.align	1
  21              		.thumb
  22              		.thumb_func
  24              	flash_SaveLog:
  25              	.LFB4:
  26              		.file 1 "misc.c"
   1:misc.c        **** #include "app.h"
   2:misc.c        **** 
   3:misc.c        **** // Checa se os dados lidos da FLASH estão corretos
   4:misc.c        **** int check_Values(void) {
   5:misc.c        **** 	tParServo* parServo;
   6:misc.c        **** 	int x; for(x=0;x<SERVO_N_MODULE;x++) {
   7:misc.c        **** 		parServo = (tParServo*)control.servo[x].par;
   8:misc.c        **** 
   9:misc.c        **** 		if ( (parServo->offset < minOFFSET_US) || (parServo->offset > maxOFFSET_US) ) return errSERVO_PAR
  10:misc.c        **** 		if ( (parServo->init < minSERVO_US) || (parServo->init > maxSERVO_US) ) return errSERVO_PAR_INIT;
  11:misc.c        **** 		if ( (parServo->min < minSERVO_US) || (parServo->min > maxSERVO_US) ) return errSERVO_PAR_MIM;
  12:misc.c        **** 		if ( (parServo->max < minSERVO_US) || (parServo->max > maxSERVO_US) ) return errSERVO_PAR_MAX;
  13:misc.c        **** 		if ( (parServo->timeProgress < minTIME_PROGRESS) || (parServo->timeProgress > maxTIME_PROGRESS) )
  14:misc.c        **** 		if ( (parServo->timeActiveOff < minTIME_OFF) || (parServo->timeActiveOff > maxTIME_OFF) ) return 
  15:misc.c        **** 	}
  16:misc.c        **** 
  17:misc.c        **** 	return pdOK;
  18:misc.c        **** }
  19:misc.c        **** 
  20:misc.c        **** // ###########################################################################################
  21:misc.c        **** // VALORES PADRÕES
  22:misc.c        **** void par_ValuesDefaults(void) {
  23:misc.c        **** 	#if (LOG_APP == pdON)
  24:misc.c        **** 	plog("ALL VALUE DEFAULT"CMD_TERMINATOR);
  25:misc.c        **** 	#endif
  26:misc.c        **** 
  27:misc.c        **** 	tParServo* parServo;
  28:misc.c        **** 	int x; for(x=0;x<SERVO_N_MODULE;x++) {
  29:misc.c        **** 		parServo = (tParServo*)control.servo[x].par;
  30:misc.c        **** 		parServo->offset = 0;
  31:misc.c        **** 		parServo->init = 1500;
  32:misc.c        **** 		parServo->min = minSERVO_US;
  33:misc.c        **** 		parServo->max = maxSERVO_US;
  34:misc.c        **** 		parServo->timeProgress = 0;
  35:misc.c        **** 		parServo->timeActiveOff = 0;
  36:misc.c        **** 	}
  37:misc.c        **** }
  38:misc.c        **** 
  39:misc.c        **** 
  40:misc.c        **** // ###########################################################################################
  41:misc.c        **** // GERENCIAMENTO DE VALORES ARMAZENADOS NO FINAL DA FLASH DE PROGRAMA
  42:misc.c        **** 
  43:misc.c        **** // Lê valores de configurações na flash, caso não conter valores válidos, colocar valores padrões
  44:misc.c        **** // Também lê os logs de erros
  45:misc.c        **** void flash_Load(void) {
  46:misc.c        **** 	int x, y;
  47:misc.c        **** 	tDataFlash* p = (tDataFlash*) (0xf000);
  48:misc.c        **** 	tLogFlash* pLog = (tLogFlash*) (0xe000);
  49:misc.c        **** 	// calcular o CRC da flash
  50:misc.c        **** 	u16 crc = crc16_MODBUS(p, (sizeof(tDataFlash))-2);
  51:misc.c        **** 
  52:misc.c        **** 	// carregar os logs de erro
  53:misc.c        **** 	tDataLog* pl = pLog->err;
  54:misc.c        **** 	for(x=0;x<nLOG;x++) {
  55:misc.c        **** 		// se o os valores da flash forem inválidos  (ID) ou o código for 0xFF, não há erro gravados
  56:misc.c        **** 		if (pl->code == 0xFF) {
  57:misc.c        **** 			control.err[x].countTick = 0;
  58:misc.c        **** 			control.err[x].code = 0;
  59:misc.c        **** 		} else {
  60:misc.c        **** 			control.err[x].countTick = pl->countTick;
  61:misc.c        **** 			control.err[x].code = pl->code;
  62:misc.c        **** 		}
  63:misc.c        **** 		pl++;
  64:misc.c        **** 	}
  65:misc.c        **** 
  66:misc.c        **** 	// Se o ID está correto e CRC errado, é porque houve algum erro de hardware ou durante a gravação
  67:misc.c        **** 	if ( (crc != p->crc) && (p->id == idFLASH) ) {
  68:misc.c        **** 		showVicError(errCRC_FLASH); // trava no loop sinalizando o erro
  69:misc.c        **** 	// Se o CRC e o ID estão corretos vamos carregar todos os valores
  70:misc.c        **** 	} if ( (crc == p->crc) && (p->id == idFLASH) )  {
  71:misc.c        **** 		#if (LOG_APP == pdON)
  72:misc.c        **** 		plog("LOAD FLASH id:0x%x crc:%d"CMD_TERMINATOR, p->id, p->crc);
  73:misc.c        **** 		#endif
  74:misc.c        **** 
  75:misc.c        **** 		tParServo* pserv = p->parServo;
  76:misc.c        **** 		s32* par;
  77:misc.c        **** 		for(x=0;x<SERVO_N_MODULE;x++) {
  78:misc.c        **** 			par = &pserv->offset;
  79:misc.c        **** 			for(y=0;y<nPAR_SERVO;y++) control.servo[x].par[y] = *par++;
  80:misc.c        **** 			pserv++;
  81:misc.c        **** 		}
  82:misc.c        **** 	} else {
  83:misc.c        **** 		// Todos os parametros assumirem valores padrões
  84:misc.c        **** 		par_ValuesDefaults();
  85:misc.c        **** 		flash_Save();
  86:misc.c        **** 	}
  87:misc.c        **** }
  88:misc.c        **** 
  89:misc.c        **** // Salvas dados de calibração no final da flash
  90:misc.c        **** #include "vic.h"
  91:misc.c        **** int flash_Save(void) {
  92:misc.c        **** 	int x,y;
  93:misc.c        **** 	u8 dataBuf[lenFLASH];
  94:misc.c        **** 	tDataFlash* p = (tDataFlash*) dataBuf;
  95:misc.c        **** 
  96:misc.c        **** 	irq_Disable(); 		// Desabilitar interrupções
  97:misc.c        **** 
  98:misc.c        **** 	for(x=0;x<lenFLASH;x++) dataBuf[x] = 0xFF;
  99:misc.c        **** 
 100:misc.c        **** 	// Antes de gravar na flash é preciso preparar o setor para gravação
 101:misc.c        **** 	if (iap_ClearSectors(15,15) != pdPASS) return pdFAIL;
 102:misc.c        **** 
 103:misc.c        **** 	p->id = idFLASH;
 104:misc.c        **** 	//p->par.offset1 = pPar->offset1;
 105:misc.c        **** 
 106:misc.c        **** 	tParServo* pserv = p->parServo;
 107:misc.c        **** 	s32* par;
 108:misc.c        **** 	for(x=0;x<SERVO_N_MODULE;x++) {
 109:misc.c        **** 		par = &pserv->offset;
 110:misc.c        **** 		for(y=0;y<nPAR_SERVO;y++) *par++=control.servo[x].par[y];
 111:misc.c        **** 		pserv++;
 112:misc.c        **** 	}
 113:misc.c        **** 
 114:misc.c        **** 	p->crc = crc16_MODBUS(dataBuf, (sizeof(tDataFlash))-2);
 115:misc.c        **** 
 116:misc.c        **** 	// gravar na FLASH. Somente aceita buffers de tamanhos de 256, 512, 1024 ou 4096 KB dependendo do 
 117:misc.c        **** 	if (iap_WriteSectors (0xf000, (u8*)dataBuf, lenFLASH) != pdPASS) return pdFAIL;
 118:misc.c        **** 
 119:misc.c        **** 	irq_Enable(); 	// Habilitar interrupções
 120:misc.c        **** 	control.ticks = 0; // Inicializa o ticks para que o relé seja atracado navamente caso se demorou m
 121:misc.c        **** 
 122:misc.c        **** 	#if (LOG_APP == pdON)
 123:misc.c        **** 	plog("SAVE FLASH crc = %d"CMD_TERMINATOR, p->crc);
 124:misc.c        **** 	#endif
 125:misc.c        **** 
 126:misc.c        **** 	return pdPASS;
 127:misc.c        **** }
 128:misc.c        **** 
 129:misc.c        **** static int flash_SaveLog(void) {
  27              		.loc 1 129 0
  28              		.cfi_startproc
  29              		@ args = 0, pretend = 0, frame = 256
  30              		@ frame_needed = 0, uses_anonymous_args = 0
  31 0000 10B5     		push	{r4, lr}
  32              	.LCFI0:
  33              		.cfi_def_cfa_offset 8
  34              		.cfi_offset 4, -8
  35              		.cfi_offset 14, -4
 130:misc.c        **** 	int x;
 131:misc.c        **** 	u8 dataBuf[lenFLASH_LOG];
 132:misc.c        **** 	tLogFlash* p = (tLogFlash*) dataBuf;
 133:misc.c        **** 
 134:misc.c        **** 	for(x=0;x<lenFLASH_LOG;x++) dataBuf[x] = 0xFF;
  36              		.loc 1 134 0
  37 0002 0023     		movs	r3, #0
 129:misc.c        **** 	int x;
  38              		.loc 1 129 0
  39 0004 C0B0     		sub	sp, sp, #256
  40              	.LCFI1:
  41              		.cfi_def_cfa_offset 264
  42              	.LVL0:
  43              		.loc 1 134 0
  44 0006 FF22     		movs	r2, #255
  45              	.LVL1:
  46              	.L2:
  47              		.loc 1 134 0 is_stmt 0 discriminator 3
  48 0008 0DF80320 		strb	r2, [sp, r3]
  49 000c 0133     		adds	r3, r3, #1
  50              	.LVL2:
  51 000e B3F5807F 		cmp	r3, #256
  52 0012 F9D1     		bne	.L2
 135:misc.c        **** 
 136:misc.c        **** 	// Antes de gravar na flash é preciso preparar o setor para gravação
 137:misc.c        **** 	if (iap_ClearSectors(14,14) != pdPASS) return pdFAIL;
  53              		.loc 1 137 0 is_stmt 1
  54 0014 0E21     		movs	r1, #14
  55 0016 0846     		mov	r0, r1
  56 0018 FFF7FEFF 		bl	iap_ClearSectors
  57              	.LVL3:
  58 001c 0128     		cmp	r0, #1
  59 001e 20D1     		bne	.L5
  60 0020 6A46     		mov	r2, sp
 138:misc.c        **** 
 139:misc.c        **** 	tDataLog* pl = p->err;
 140:misc.c        **** 	for(x=0;x<nLOG;x++) {
 141:misc.c        **** 		pl->countTick = control.err[x].countTick;
  61              		.loc 1 141 0 discriminator 3
  62 0022 114C     		ldr	r4, .L9
  63 0024 0023     		movs	r3, #0
  64              	.L4:
  65              	.LVL4:
  66 0026 03EB8301 		add	r1, r3, r3, lsl #2
  67 002a 2144     		add	r1, r1, r4
  68 002c D1F80500 		ldr	r0, [r1, #5]	@ unaligned
 140:misc.c        **** 		pl->countTick = control.err[x].countTick;
  69              		.loc 1 140 0 discriminator 3
  70 0030 0133     		adds	r3, r3, #1
  71              	.LVL5:
 142:misc.c        **** 		pl->code = control.err[x].code;
  72              		.loc 1 142 0 discriminator 3
  73 0032 497A     		ldrb	r1, [r1, #9]	@ zero_extendqisi2
 140:misc.c        **** 		pl->countTick = control.err[x].countTick;
  74              		.loc 1 140 0 discriminator 3
  75 0034 1E2B     		cmp	r3, #30
 141:misc.c        **** 		pl->code = control.err[x].code;
  76              		.loc 1 141 0 discriminator 3
  77 0036 1060     		str	r0, [r2]	@ unaligned
  78              		.loc 1 142 0 discriminator 3
  79 0038 1171     		strb	r1, [r2, #4]
 143:misc.c        **** 		pl++;
  80              		.loc 1 143 0 discriminator 3
  81 003a 02F10502 		add	r2, r2, #5
  82              	.LVL6:
 140:misc.c        **** 		pl->countTick = control.err[x].countTick;
  83              		.loc 1 140 0 discriminator 3
  84 003e F2D1     		bne	.L4
 144:misc.c        **** 	}
 145:misc.c        **** 
 146:misc.c        **** 	p->crc = crc16_MODBUS(dataBuf, (sizeof(tLogFlash))-2);
  85              		.loc 1 146 0
  86 0040 9621     		movs	r1, #150
  87 0042 6846     		mov	r0, sp
  88 0044 FFF7FEFF 		bl	crc16_MODBUS
  89              	.LVL7:
 147:misc.c        **** 
 148:misc.c        **** 	// gravar na FLASH. Somente aceita buffers de tamanhos de 256, 512, 1024 ou 4096 KB dependendo do 
 149:misc.c        **** 	if (iap_WriteSectors (0xe000, (u8*)dataBuf, lenFLASH_LOG) != pdPASS) return pdFAIL;
  90              		.loc 1 149 0
  91 0048 4FF48072 		mov	r2, #256
 146:misc.c        **** 
  92              		.loc 1 146 0
  93 004c ADF89600 		strh	r0, [sp, #150]	@ movhi
  94              		.loc 1 149 0
  95 0050 6946     		mov	r1, sp
  96 0052 4FF46040 		mov	r0, #57344
  97 0056 FFF7FEFF 		bl	iap_WriteSectors
  98              	.LVL8:
 137:misc.c        **** 
  99              		.loc 1 137 0
 100 005a 431E     		subs	r3, r0, #1
 101 005c 5842     		rsbs	r0, r3, #0
 102 005e 5841     		adcs	r0, r0, r3
 103 0060 00E0     		b	.L3
 104              	.L5:
 105 0062 0020     		movs	r0, #0
 106              	.L3:
 150:misc.c        **** 
 151:misc.c        **** 	return pdPASS;
 152:misc.c        **** }
 107              		.loc 1 152 0
 108 0064 40B0     		add	sp, sp, #256
 109              	.LCFI2:
 110              		.cfi_def_cfa_offset 8
 111              	.LVL9:
 112              		@ sp needed
 113 0066 10BD     		pop	{r4, pc}
 114              	.LVL10:
 115              	.L10:
 116              		.align	2
 117              	.L9:
 118 0068 00000000 		.word	control
 119              		.cfi_endproc
 120              	.LFE4:
 122              		.section	.text.check_Values,"ax",%progbits
 123              		.align	1
 124              		.global	check_Values
 125              		.thumb
 126              		.thumb_func
 128              	check_Values:
 129              	.LFB0:
   4:misc.c        **** 	tParServo* parServo;
 130              		.loc 1 4 0
 131              		.cfi_startproc
 132              		@ args = 0, pretend = 0, frame = 0
 133              		@ frame_needed = 0, uses_anonymous_args = 0
 134              	.LVL11:
 135 0000 10B5     		push	{r4, lr}
 136              	.LCFI3:
 137              		.cfi_def_cfa_offset 8
 138              		.cfi_offset 4, -8
 139              		.cfi_offset 14, -4
  10:misc.c        **** 		if ( (parServo->min < minSERVO_US) || (parServo->min > maxSERVO_US) ) return errSERVO_PAR_MIM;
 140              		.loc 1 10 0
 141 0002 40F65432 		movw	r2, #2900
   9:misc.c        **** 		if ( (parServo->init < minSERVO_US) || (parServo->init > maxSERVO_US) ) return errSERVO_PAR_INIT;
 142              		.loc 1 9 0
 143 0006 40F6B834 		movw	r4, #3000
 144 000a 194B     		ldr	r3, .L21
 145 000c 03F1C400 		add	r0, r3, #196
 146              	.LVL12:
 147              	.L13:
 148 0010 D3F8B010 		ldr	r1, [r3, #176]
 149 0014 01F2DC51 		addw	r1, r1, #1500
 150 0018 A142     		cmp	r1, r4
 151 001a 1DD8     		bhi	.L14
  10:misc.c        **** 		if ( (parServo->min < minSERVO_US) || (parServo->min > maxSERVO_US) ) return errSERVO_PAR_MIM;
 152              		.loc 1 10 0
 153 001c D3F8B410 		ldr	r1, [r3, #180]
 154 0020 6439     		subs	r1, r1, #100
 155 0022 9142     		cmp	r1, r2
 156 0024 1AD8     		bhi	.L15
  11:misc.c        **** 		if ( (parServo->max < minSERVO_US) || (parServo->max > maxSERVO_US) ) return errSERVO_PAR_MAX;
 157              		.loc 1 11 0
 158 0026 D3F8B810 		ldr	r1, [r3, #184]
 159 002a 6439     		subs	r1, r1, #100
 160 002c 9142     		cmp	r1, r2
 161 002e 17D8     		bhi	.L16
  12:misc.c        **** 		if ( (parServo->timeProgress < minTIME_PROGRESS) || (parServo->timeProgress > maxTIME_PROGRESS) )
 162              		.loc 1 12 0
 163 0030 D3F8BC10 		ldr	r1, [r3, #188]
 164 0034 6439     		subs	r1, r1, #100
 165 0036 9142     		cmp	r1, r2
 166 0038 14D8     		bhi	.L17
  13:misc.c        **** 		if ( (parServo->timeActiveOff < minTIME_OFF) || (parServo->timeActiveOff > maxTIME_OFF) ) return 
 167              		.loc 1 13 0
 168 003a D3F8C410 		ldr	r1, [r3, #196]
 169 003e B1F5FA7F 		cmp	r1, #500
 170 0042 11D8     		bhi	.L18
  14:misc.c        **** 	}
 171              		.loc 1 14 0
 172 0044 D3F8C010 		ldr	r1, [r3, #192]
 173 0048 B1F5FA7F 		cmp	r1, #500
 174 004c 0ED8     		bhi	.L19
 175 004e 1C33     		adds	r3, r3, #28
 176              	.LVL13:
   6:misc.c        **** 		parServo = (tParServo*)control.servo[x].par;
 177              		.loc 1 6 0 discriminator 2
 178 0050 8342     		cmp	r3, r0
 179 0052 DDD1     		bne	.L13
  17:misc.c        **** }
 180              		.loc 1 17 0
 181 0054 0120     		movs	r0, #1
 182 0056 10BD     		pop	{r4, pc}
 183              	.LVL14:
 184              	.L14:
   9:misc.c        **** 		if ( (parServo->init < minSERVO_US) || (parServo->init > maxSERVO_US) ) return errSERVO_PAR_INIT;
 185              		.loc 1 9 0
 186 0058 6520     		movs	r0, #101
 187 005a 10BD     		pop	{r4, pc}
 188              	.L15:
  10:misc.c        **** 		if ( (parServo->min < minSERVO_US) || (parServo->min > maxSERVO_US) ) return errSERVO_PAR_MIM;
 189              		.loc 1 10 0
 190 005c 6620     		movs	r0, #102
 191 005e 10BD     		pop	{r4, pc}
 192              	.L16:
  11:misc.c        **** 		if ( (parServo->max < minSERVO_US) || (parServo->max > maxSERVO_US) ) return errSERVO_PAR_MAX;
 193              		.loc 1 11 0
 194 0060 6720     		movs	r0, #103
 195 0062 10BD     		pop	{r4, pc}
 196              	.L17:
  12:misc.c        **** 		if ( (parServo->timeProgress < minTIME_PROGRESS) || (parServo->timeProgress > maxTIME_PROGRESS) )
 197              		.loc 1 12 0
 198 0064 6820     		movs	r0, #104
 199 0066 10BD     		pop	{r4, pc}
 200              	.L18:
  13:misc.c        **** 		if ( (parServo->timeActiveOff < minTIME_OFF) || (parServo->timeActiveOff > maxTIME_OFF) ) return 
 201              		.loc 1 13 0
 202 0068 6920     		movs	r0, #105
 203 006a 10BD     		pop	{r4, pc}
 204              	.L19:
  14:misc.c        **** 	}
 205              		.loc 1 14 0
 206 006c 6A20     		movs	r0, #106
  18:misc.c        **** 
 207              		.loc 1 18 0
 208 006e 10BD     		pop	{r4, pc}
 209              	.L22:
 210              		.align	2
 211              	.L21:
 212 0070 00000000 		.word	control
 213              		.cfi_endproc
 214              	.LFE0:
 216              		.section	.text.par_ValuesDefaults,"ax",%progbits
 217              		.align	1
 218              		.global	par_ValuesDefaults
 219              		.thumb
 220              		.thumb_func
 222              	par_ValuesDefaults:
 223              	.LFB1:
  22:misc.c        **** 	#if (LOG_APP == pdON)
 224              		.loc 1 22 0
 225              		.cfi_startproc
 226              		@ args = 0, pretend = 0, frame = 0
 227              		@ frame_needed = 0, uses_anonymous_args = 0
 228              	.LVL15:
 229 0000 30B5     		push	{r4, r5, lr}
 230              	.LCFI4:
 231              		.cfi_def_cfa_offset 12
 232              		.cfi_offset 4, -12
 233              		.cfi_offset 5, -8
 234              		.cfi_offset 14, -4
  33:misc.c        **** 		parServo->timeProgress = 0;
 235              		.loc 1 33 0
 236 0002 40F6B830 		movw	r0, #3000
  31:misc.c        **** 		parServo->min = minSERVO_US;
 237              		.loc 1 31 0
 238 0006 40F2DC55 		movw	r5, #1500
 239 000a 0A4B     		ldr	r3, .L26
  30:misc.c        **** 		parServo->init = 1500;
 240              		.loc 1 30 0
 241 000c 0022     		movs	r2, #0
 242 000e 03F1C401 		add	r1, r3, #196
  32:misc.c        **** 		parServo->max = maxSERVO_US;
 243              		.loc 1 32 0
 244 0012 6424     		movs	r4, #100
 245              	.LVL16:
 246              	.L24:
  30:misc.c        **** 		parServo->init = 1500;
 247              		.loc 1 30 0 discriminator 3
 248 0014 C3F8B020 		str	r2, [r3, #176]
  31:misc.c        **** 		parServo->min = minSERVO_US;
 249              		.loc 1 31 0 discriminator 3
 250 0018 C3F8B450 		str	r5, [r3, #180]
  32:misc.c        **** 		parServo->max = maxSERVO_US;
 251              		.loc 1 32 0 discriminator 3
 252 001c C3F8B840 		str	r4, [r3, #184]
  33:misc.c        **** 		parServo->timeProgress = 0;
 253              		.loc 1 33 0 discriminator 3
 254 0020 C3F8BC00 		str	r0, [r3, #188]
  34:misc.c        **** 		parServo->timeActiveOff = 0;
 255              		.loc 1 34 0 discriminator 3
 256 0024 C3F8C420 		str	r2, [r3, #196]
  35:misc.c        **** 	}
 257              		.loc 1 35 0 discriminator 3
 258 0028 C3F8C020 		str	r2, [r3, #192]
 259 002c 1C33     		adds	r3, r3, #28
 260              	.LVL17:
  28:misc.c        **** 		parServo = (tParServo*)control.servo[x].par;
 261              		.loc 1 28 0 discriminator 3
 262 002e 8B42     		cmp	r3, r1
 263 0030 F0D1     		bne	.L24
  37:misc.c        **** 
 264              		.loc 1 37 0
 265 0032 30BD     		pop	{r4, r5, pc}
 266              	.L27:
 267              		.align	2
 268              	.L26:
 269 0034 00000000 		.word	control
 270              		.cfi_endproc
 271              	.LFE1:
 273              		.section	.text.flash_Save,"ax",%progbits
 274              		.align	1
 275              		.global	flash_Save
 276              		.thumb
 277              		.thumb_func
 279              	flash_Save:
 280              	.LFB3:
  91:misc.c        **** 	int x,y;
 281              		.loc 1 91 0
 282              		.cfi_startproc
 283              		@ args = 0, pretend = 0, frame = 512
 284              		@ frame_needed = 0, uses_anonymous_args = 0
 285 0000 70B5     		push	{r4, r5, r6, lr}
 286              	.LCFI5:
 287              		.cfi_def_cfa_offset 16
 288              		.cfi_offset 4, -16
 289              		.cfi_offset 5, -12
 290              		.cfi_offset 6, -8
 291              		.cfi_offset 14, -4
 292 0002 ADF5007D 		sub	sp, sp, #512
 293              	.LCFI6:
 294              		.cfi_def_cfa_offset 528
 295              	.LVL18:
  96:misc.c        **** 
 296              		.loc 1 96 0
 297              		.syntax unified
 298              	@ 96 "misc.c" 1
 299 0006 72B6     		cpsid i
 300              	@ 0 "" 2
 301              	.LVL19:
  98:misc.c        **** 
 302              		.loc 1 98 0
 303              		.thumb
 304              		.syntax unified
 305 0008 0023     		movs	r3, #0
 306 000a FF22     		movs	r2, #255
 307              	.LVL20:
 308              	.L29:
  98:misc.c        **** 
 309              		.loc 1 98 0 is_stmt 0 discriminator 3
 310 000c 0DF80320 		strb	r2, [sp, r3]
 311 0010 0133     		adds	r3, r3, #1
 312              	.LVL21:
 313 0012 B3F5007F 		cmp	r3, #512
 314 0016 F9D1     		bne	.L29
 101:misc.c        **** 
 315              		.loc 1 101 0 is_stmt 1
 316 0018 0F21     		movs	r1, #15
 317 001a 0846     		mov	r0, r1
 318 001c FFF7FEFF 		bl	iap_ClearSectors
 319              	.LVL22:
 320 0020 0128     		cmp	r0, #1
 321 0022 01D0     		beq	.L30
 322              	.L34:
 323 0024 0020     		movs	r0, #0
 324 0026 28E0     		b	.L31
 325              	.L30:
 103:misc.c        **** 	//p->par.offset1 = pPar->offset1;
 326              		.loc 1 103 0
 327 0028 154B     		ldr	r3, .L38
 328 002a 164D     		ldr	r5, .L38+4
 329 002c 0093     		str	r3, [sp]
 330              	.LVL23:
 331 002e 06AA     		add	r2, sp, #24
 108:misc.c        **** 		par = &pserv->offset;
 332              		.loc 1 108 0
 333 0030 0023     		movs	r3, #0
 334 0032 1C24     		movs	r4, #28
 335              	.LVL24:
 336              	.L33:
 337 0034 04FB0351 		mla	r1, r4, r3, r5
 338 0038 A2F11800 		sub	r0, r2, #24
 339 003c AC31     		adds	r1, r1, #172
 340              	.LVL25:
 341              	.L32:
 110:misc.c        **** 		pserv++;
 342              		.loc 1 110 0 discriminator 3
 343 003e 51F8046F 		ldr	r6, [r1, #4]!
 344 0042 40F8046F 		str	r6, [r0, #4]!
 345 0046 8242     		cmp	r2, r0
 346 0048 F9D1     		bne	.L32
 347              	.LVL26:
 108:misc.c        **** 		par = &pserv->offset;
 348              		.loc 1 108 0 discriminator 2
 349 004a 0133     		adds	r3, r3, #1
 350              	.LVL27:
 351 004c 072B     		cmp	r3, #7
 352 004e 02F11802 		add	r2, r2, #24
 353              	.LVL28:
 354 0052 EFD1     		bne	.L33
 114:misc.c        **** 
 355              		.loc 1 114 0
 356 0054 AC21     		movs	r1, #172
 357 0056 6846     		mov	r0, sp
 358 0058 FFF7FEFF 		bl	crc16_MODBUS
 359              	.LVL29:
 117:misc.c        **** 
 360              		.loc 1 117 0
 361 005c 4FF40072 		mov	r2, #512
 114:misc.c        **** 
 362              		.loc 1 114 0
 363 0060 ADF8AC00 		strh	r0, [sp, #172]	@ movhi
 117:misc.c        **** 
 364              		.loc 1 117 0
 365 0064 6946     		mov	r1, sp
 366 0066 4FF47040 		mov	r0, #61440
 367 006a FFF7FEFF 		bl	iap_WriteSectors
 368              	.LVL30:
 369 006e 0128     		cmp	r0, #1
 370 0070 D8D1     		bne	.L34
 119:misc.c        **** 	control.ticks = 0; // Inicializa o ticks para que o relé seja atracado navamente caso se demorou m
 371              		.loc 1 119 0
 372              		.syntax unified
 373              	@ 119 "misc.c" 1
 374 0072 62B6     		cpsie i
 375              	@ 0 "" 2
 120:misc.c        **** 
 376              		.loc 1 120 0
 377              		.thumb
 378              		.syntax unified
 379 0074 034B     		ldr	r3, .L38+4
 380 0076 0022     		movs	r2, #0
 381 0078 1A60     		str	r2, [r3]
 382              	.L31:
 127:misc.c        **** 
 383              		.loc 1 127 0
 384 007a 0DF5007D 		add	sp, sp, #512
 385              	.LCFI7:
 386              		.cfi_def_cfa_offset 16
 387              	.LVL31:
 388              		@ sp needed
 389 007e 70BD     		pop	{r4, r5, r6, pc}
 390              	.LVL32:
 391              	.L39:
 392              		.align	2
 393              	.L38:
 394 0080 04A5555A 		.word	1515562244
 395 0084 00000000 		.word	control
 396              		.cfi_endproc
 397              	.LFE3:
 399              		.section	.text.flash_Load,"ax",%progbits
 400              		.align	1
 401              		.global	flash_Load
 402              		.thumb
 403              		.thumb_func
 405              	flash_Load:
 406              	.LFB2:
  45:misc.c        **** 	int x, y;
 407              		.loc 1 45 0
 408              		.cfi_startproc
 409              		@ args = 0, pretend = 0, frame = 0
 410              		@ frame_needed = 0, uses_anonymous_args = 0
 411              	.LVL33:
 412 0000 F8B5     		push	{r3, r4, r5, r6, r7, lr}
 413              	.LCFI8:
 414              		.cfi_def_cfa_offset 24
 415              		.cfi_offset 3, -24
 416              		.cfi_offset 4, -20
 417              		.cfi_offset 5, -16
 418              		.cfi_offset 6, -12
 419              		.cfi_offset 7, -8
 420              		.cfi_offset 14, -4
  50:misc.c        **** 
 421              		.loc 1 50 0
 422 0002 AC21     		movs	r1, #172
 423 0004 4FF47040 		mov	r0, #61440
 424 0008 FFF7FEFF 		bl	crc16_MODBUS
 425              	.LVL34:
 426 000c 2849     		ldr	r1, .L53
  54:misc.c        **** 		// se o os valores da flash forem inválidos  (ID) ou o código for 0xFF, não há erro gravados
 427              		.loc 1 54 0
 428 000e 0022     		movs	r2, #0
  50:misc.c        **** 
 429              		.loc 1 50 0
 430 0010 0646     		mov	r6, r0
 431              	.LVL35:
 432 0012 0C46     		mov	r4, r1
  57:misc.c        **** 			control.err[x].code = 0;
 433              		.loc 1 57 0
 434 0014 1046     		mov	r0, r2
  53:misc.c        **** 	for(x=0;x<nLOG;x++) {
 435              		.loc 1 53 0
 436 0016 4FF46045 		mov	r5, #57344
 437              	.LVL36:
 438              	.L43:
  56:misc.c        **** 			control.err[x].countTick = 0;
 439              		.loc 1 56 0
 440 001a 2F79     		ldrb	r7, [r5, #4]	@ zero_extendqisi2
 441 001c 9300     		lsls	r3, r2, #2
 442 001e FF2F     		cmp	r7, #255
 443 0020 07D1     		bne	.L41
  57:misc.c        **** 			control.err[x].code = 0;
 444              		.loc 1 57 0
 445 0022 1344     		add	r3, r3, r2
 446 0024 2344     		add	r3, r3, r4
 447 0026 5871     		strb	r0, [r3, #5]
 448 0028 9871     		strb	r0, [r3, #6]
 449 002a D871     		strb	r0, [r3, #7]
 450 002c 1872     		strb	r0, [r3, #8]
  58:misc.c        **** 		} else {
 451              		.loc 1 58 0
 452 002e 4872     		strb	r0, [r1, #9]
 453 0030 06E0     		b	.L42
 454              	.L41:
  60:misc.c        **** 			control.err[x].code = pl->code;
 455              		.loc 1 60 0
 456 0032 D5F800E0 		ldr	lr, [r5]	@ unaligned
 457 0036 1344     		add	r3, r3, r2
 458 0038 2344     		add	r3, r3, r4
 459 003a C3F805E0 		str	lr, [r3, #5]	@ unaligned
  61:misc.c        **** 		}
 460              		.loc 1 61 0
 461 003e 4F72     		strb	r7, [r1, #9]
 462              	.L42:
  54:misc.c        **** 		// se o os valores da flash forem inválidos  (ID) ou o código for 0xFF, não há erro gravados
 463              		.loc 1 54 0 discriminator 2
 464 0040 0132     		adds	r2, r2, #1
 465              	.LVL37:
 466 0042 1E2A     		cmp	r2, #30
  63:misc.c        **** 	}
 467              		.loc 1 63 0 discriminator 2
 468 0044 05F10505 		add	r5, r5, #5
 469              	.LVL38:
 470 0048 01F10501 		add	r1, r1, #5
  54:misc.c        **** 		// se o os valores da flash forem inválidos  (ID) ou o código for 0xFF, não há erro gravados
 471              		.loc 1 54 0 discriminator 2
 472 004c E5D1     		bne	.L43
  67:misc.c        **** 		showVicError(errCRC_FLASH); // trava no loop sinalizando o erro
 473              		.loc 1 67 0
 474 004e 4FF47043 		mov	r3, #61440
 475 0052 B3F8AC20 		ldrh	r2, [r3, #172]
 476              	.LVL39:
 477 0056 B242     		cmp	r2, r6
 478 0058 06D0     		beq	.L44
  67:misc.c        **** 		showVicError(errCRC_FLASH); // trava no loop sinalizando o erro
 479              		.loc 1 67 0 is_stmt 0 discriminator 1
 480 005a 1A68     		ldr	r2, [r3]
 481 005c 154B     		ldr	r3, .L53+4
 482 005e 9A42     		cmp	r2, r3
 483 0060 02D1     		bne	.L44
  68:misc.c        **** 	// Se o CRC e o ID estão corretos vamos carregar todos os valores
 484              		.loc 1 68 0 is_stmt 1
 485 0062 6420     		movs	r0, #100
 486 0064 FFF7FEFF 		bl	showVicError
 487              	.LVL40:
 488              	.L44:
  70:misc.c        **** 		#if (LOG_APP == pdON)
 489              		.loc 1 70 0
 490 0068 4FF47043 		mov	r3, #61440
 491 006c B3F8AC20 		ldrh	r2, [r3, #172]
 492 0070 B242     		cmp	r2, r6
 493 0072 16D1     		bne	.L45
  70:misc.c        **** 		#if (LOG_APP == pdON)
 494              		.loc 1 70 0 is_stmt 0 discriminator 1
 495 0074 1A68     		ldr	r2, [r3]
 496 0076 0F4B     		ldr	r3, .L53+4
 497 0078 9A42     		cmp	r2, r3
 498 007a 12D1     		bne	.L45
 499              	.LBB2:
  75:misc.c        **** 		s32* par;
 500              		.loc 1 75 0 is_stmt 1
 501 007c 4FF20403 		movw	r3, #61444
 502              	.LVL41:
 503 0080 0022     		movs	r2, #0
 504              	.LVL42:
 505              	.L47:
 506 0082 02F1AC01 		add	r1, r2, #172
 507 0086 2144     		add	r1, r1, r4
 508 0088 03F11800 		add	r0, r3, #24
 509              	.LVL43:
 510              	.L46:
  79:misc.c        **** 			pserv++;
 511              		.loc 1 79 0 discriminator 3
 512 008c 53F8045B 		ldr	r5, [r3], #4
 513              	.LVL44:
 514 0090 9842     		cmp	r0, r3
 515 0092 41F8045F 		str	r5, [r1, #4]!
 516              	.LVL45:
 517 0096 F9D1     		bne	.L46
 518              	.LVL46:
 519 0098 1C32     		adds	r2, r2, #28
  77:misc.c        **** 			par = &pserv->offset;
 520              		.loc 1 77 0 discriminator 2
 521 009a C42A     		cmp	r2, #196
 522 009c 0346     		mov	r3, r0
 523              	.LVL47:
 524 009e F0D1     		bne	.L47
 525 00a0 F8BD     		pop	{r3, r4, r5, r6, r7, pc}
 526              	.LVL48:
 527              	.L45:
 528              	.LBE2:
  84:misc.c        **** 		flash_Save();
 529              		.loc 1 84 0
 530 00a2 FFF7FEFF 		bl	par_ValuesDefaults
 531              	.LVL49:
  87:misc.c        **** 
 532              		.loc 1 87 0
 533 00a6 BDE8F840 		pop	{r3, r4, r5, r6, r7, lr}
 534              	.LCFI9:
 535              		.cfi_restore 14
 536              		.cfi_restore 7
 537              		.cfi_restore 6
 538              		.cfi_restore 5
 539              		.cfi_restore 4
 540              		.cfi_restore 3
 541              		.cfi_def_cfa_offset 0
 542              	.LVL50:
  85:misc.c        **** 	}
 543              		.loc 1 85 0
 544 00aa FFF7FEBF 		b	flash_Save
 545              	.LVL51:
 546              	.L54:
 547 00ae 00BF     		.align	2
 548              	.L53:
 549 00b0 00000000 		.word	control
 550 00b4 04A5555A 		.word	1515562244
 551              		.cfi_endproc
 552              	.LFE2:
 554              		.section	.text.flash_ClearLogError,"ax",%progbits
 555              		.align	1
 556              		.global	flash_ClearLogError
 557              		.thumb
 558              		.thumb_func
 560              	flash_ClearLogError:
 561              	.LFB5:
 153:misc.c        **** 
 154:misc.c        **** // limpa os logs de erro
 155:misc.c        **** int flash_ClearLogError(void) {
 562              		.loc 1 155 0
 563              		.cfi_startproc
 564              		@ args = 0, pretend = 0, frame = 0
 565              		@ frame_needed = 0, uses_anonymous_args = 0
 566              		@ link register save eliminated.
 567              	.LVL52:
 156:misc.c        **** 	uint x; for(x=0; x<nLOG;x++) {
 568              		.loc 1 156 0
 569 0000 0022     		movs	r2, #0
 157:misc.c        **** 		control.err[x].countTick = 0;
 570              		.loc 1 157 0
 571 0002 1146     		mov	r1, r2
 572 0004 0648     		ldr	r0, .L58
 573              	.LVL53:
 574              	.L56:
 575              		.loc 1 157 0 is_stmt 0 discriminator 3
 576 0006 02EB8203 		add	r3, r2, r2, lsl #2
 156:misc.c        **** 	uint x; for(x=0; x<nLOG;x++) {
 577              		.loc 1 156 0 is_stmt 1 discriminator 3
 578 000a 0132     		adds	r2, r2, #1
 579              	.LVL54:
 580              		.loc 1 157 0 discriminator 3
 581 000c 0344     		add	r3, r3, r0
 156:misc.c        **** 	uint x; for(x=0; x<nLOG;x++) {
 582              		.loc 1 156 0 discriminator 3
 583 000e 1E2A     		cmp	r2, #30
 584              		.loc 1 157 0 discriminator 3
 585 0010 5971     		strb	r1, [r3, #5]
 586 0012 9971     		strb	r1, [r3, #6]
 587 0014 D971     		strb	r1, [r3, #7]
 588 0016 1972     		strb	r1, [r3, #8]
 158:misc.c        **** 		control.err[x].code = 0;
 589              		.loc 1 158 0 discriminator 3
 590 0018 5972     		strb	r1, [r3, #9]
 156:misc.c        **** 	uint x; for(x=0; x<nLOG;x++) {
 591              		.loc 1 156 0 discriminator 3
 592 001a F4D1     		bne	.L56
 159:misc.c        **** 	}
 160:misc.c        **** 
 161:misc.c        **** 	return flash_SaveLog();
 593              		.loc 1 161 0
 594 001c FFF7FEBF 		b	flash_SaveLog
 595              	.LVL55:
 596              	.L59:
 597              		.align	2
 598              	.L58:
 599 0020 00000000 		.word	control
 600              		.cfi_endproc
 601              	.LFE5:
 603              		.section	.text.flash_SaveLogError,"ax",%progbits
 604              		.align	1
 605              		.global	flash_SaveLogError
 606              		.thumb
 607              		.thumb_func
 609              	flash_SaveLogError:
 610              	.LFB6:
 162:misc.c        **** }
 163:misc.c        **** 
 164:misc.c        **** // salva o erro no primeiro slot disponivel. Salvar na posição da FLASH diferente dos parametros
 165:misc.c        **** int flash_SaveLogError(u32 countTicks, u8 n) {
 611              		.loc 1 165 0
 612              		.cfi_startproc
 613              		@ args = 0, pretend = 0, frame = 0
 614              		@ frame_needed = 0, uses_anonymous_args = 0
 615              		@ link register save eliminated.
 616              	.LVL56:
 617 0000 30B4     		push	{r4, r5}
 618              	.LCFI10:
 619              		.cfi_def_cfa_offset 8
 620              		.cfi_offset 4, -8
 621              		.cfi_offset 5, -4
 166:misc.c        **** 	int res = pdFALSE;
 167:misc.c        **** 
 168:misc.c        **** 	// encontrar até um slot vazio, uma vez encontrado salva na flash e cai fora
 169:misc.c        **** 	uint x; for(x=0; x<nLOG;x++)
 170:misc.c        **** 		if (control.err[x].code == 0) {
 622              		.loc 1 170 0
 623 0002 094C     		ldr	r4, .L64
 169:misc.c        **** 		if (control.err[x].code == 0) {
 624              		.loc 1 169 0
 625 0004 0023     		movs	r3, #0
 626              	.LVL57:
 627              	.L62:
 628              		.loc 1 170 0
 629 0006 03EB8302 		add	r2, r3, r3, lsl #2
 630 000a 2244     		add	r2, r2, r4
 631 000c 557A     		ldrb	r5, [r2, #9]	@ zero_extendqisi2
 632 000e 2DB9     		cbnz	r5, .L61
 171:misc.c        **** 			control.err[x].countTick = countTicks;
 172:misc.c        **** 			control.err[x].code = n;
 633              		.loc 1 172 0
 634 0010 5172     		strb	r1, [r2, #9]
 171:misc.c        **** 			control.err[x].countTick = countTicks;
 635              		.loc 1 171 0
 636 0012 C2F80500 		str	r0, [r2, #5]	@ unaligned
 173:misc.c        **** 			res = flash_SaveLog();
 174:misc.c        **** 			break;
 175:misc.c        **** 		}
 176:misc.c        **** 
 177:misc.c        **** 	return res;
 178:misc.c        **** }
 637              		.loc 1 178 0
 638 0016 30BC     		pop	{r4, r5}
 639              	.LCFI11:
 640              		.cfi_remember_state
 641              		.cfi_restore 5
 642              		.cfi_restore 4
 643              		.cfi_def_cfa_offset 0
 173:misc.c        **** 			res = flash_SaveLog();
 644              		.loc 1 173 0
 645 0018 FFF7FEBF 		b	flash_SaveLog
 646              	.LVL58:
 647              	.L61:
 648              	.LCFI12:
 649              		.cfi_restore_state
 169:misc.c        **** 		if (control.err[x].code == 0) {
 650              		.loc 1 169 0 discriminator 2
 651 001c 0133     		adds	r3, r3, #1
 652              	.LVL59:
 653 001e 1E2B     		cmp	r3, #30
 654 0020 F1D1     		bne	.L62
 655              		.loc 1 178 0
 656 0022 0020     		movs	r0, #0
 657              	.LVL60:
 658 0024 30BC     		pop	{r4, r5}
 659              	.LCFI13:
 660              		.cfi_restore 5
 661              		.cfi_restore 4
 662              		.cfi_def_cfa_offset 0
 663 0026 7047     		bx	lr
 664              	.L65:
 665              		.align	2
 666              	.L64:
 667 0028 00000000 		.word	control
 668              		.cfi_endproc
 669              	.LFE6:
 671              		.comm	control,424,4
 672              		.text
 673              	.Letext0:
 674              		.file 2 "uc_libc_dev/_libdef/uc_libdefs.h"
 675              		.file 3 "app.h"
 676              		.file 4 "uc_libc_dev/_arch/arm_lpc/flash/iap.h"
 677              		.file 5 "uc_libc_dev/crc/crc.h"
DEFINED SYMBOLS
                            *ABS*:00000000 misc.c
D:\_temp\_windows\ccLspT0c.s:20     .text.flash_SaveLog:00000000 $t
D:\_temp\_windows\ccLspT0c.s:24     .text.flash_SaveLog:00000000 flash_SaveLog
D:\_temp\_windows\ccLspT0c.s:118    .text.flash_SaveLog:00000068 $d
                            *COM*:000001a8 control
D:\_temp\_windows\ccLspT0c.s:123    .text.check_Values:00000000 $t
D:\_temp\_windows\ccLspT0c.s:128    .text.check_Values:00000000 check_Values
D:\_temp\_windows\ccLspT0c.s:212    .text.check_Values:00000070 $d
D:\_temp\_windows\ccLspT0c.s:217    .text.par_ValuesDefaults:00000000 $t
D:\_temp\_windows\ccLspT0c.s:222    .text.par_ValuesDefaults:00000000 par_ValuesDefaults
D:\_temp\_windows\ccLspT0c.s:269    .text.par_ValuesDefaults:00000034 $d
D:\_temp\_windows\ccLspT0c.s:274    .text.flash_Save:00000000 $t
D:\_temp\_windows\ccLspT0c.s:279    .text.flash_Save:00000000 flash_Save
D:\_temp\_windows\ccLspT0c.s:394    .text.flash_Save:00000080 $d
D:\_temp\_windows\ccLspT0c.s:400    .text.flash_Load:00000000 $t
D:\_temp\_windows\ccLspT0c.s:405    .text.flash_Load:00000000 flash_Load
D:\_temp\_windows\ccLspT0c.s:549    .text.flash_Load:000000b0 $d
D:\_temp\_windows\ccLspT0c.s:555    .text.flash_ClearLogError:00000000 $t
D:\_temp\_windows\ccLspT0c.s:560    .text.flash_ClearLogError:00000000 flash_ClearLogError
D:\_temp\_windows\ccLspT0c.s:599    .text.flash_ClearLogError:00000020 $d
D:\_temp\_windows\ccLspT0c.s:604    .text.flash_SaveLogError:00000000 $t
D:\_temp\_windows\ccLspT0c.s:609    .text.flash_SaveLogError:00000000 flash_SaveLogError
D:\_temp\_windows\ccLspT0c.s:667    .text.flash_SaveLogError:00000028 $d
                     .debug_frame:00000010 $d

UNDEFINED SYMBOLS
iap_ClearSectors
crc16_MODBUS
iap_WriteSectors
showVicError
